import { connect } from 'dva';
import React from 'react'
import Login from '../../components/login/login'

class LoginRoute extends React.Component {
  render() {

    const { login, dispatch } = this.props;
    const { isLogin } = login;

    const loginPros = {
      isLogin,
      onLogin : (values) => {
        dispatch({
          type: 'login/login',
          payload: values,
        });
      },

      onLogout : () => {
        dispatch({
          type: 'login/logout',
        });
      }
    }

    return (
      <div>
        <Login {...loginPros}/>
      </div>
    )
  }
}

function mapStateToProps(state) {
  return {
    login : state.login,
  };
}

export default connect(mapStateToProps)(LoginRoute);

